<?php

namespace IDock\Insurance\DAJIA\Response;

use IDock\Http\Response;
use IDock\Insurance\DAJIA\Response\AllDAJIAResponse;
use IDock\Printer\EPolicyDownloadPrinter;

class ElectricalInsuranceResponse extends AllDAJIAResponse
{

    public function printerInit(): Response
    {
        $electricalPrinter = new EPolicyDownloadPrinter();

        $data = $this->get('body',[]);
        $url = $data['result'][0]['returnUrl'] ?? '';

        $electricalPrinter->finish = true;
        $electricalPrinter->url = $url;

        if (!$electricalPrinter->url) {
            $electricalPrinter->doing = true;
            $electricalPrinter->finish = false;
            return $this;
        }

        $electricalPrinter->signUrl = $data['result'][0]['returnBzUrl'] ?? '';

        $this->printer = $electricalPrinter;
        return $this;
    }
}
